import { CanvasContext } from "./designType";
import { Dimension } from "./Dimension";
import { Shape } from "./Shape";

export class Mullion {
  constructor(
    public type: 'horizontal' | 'vertical',
    public dimension: Dimension,    // 使用 Dimension 表示中梃的尺寸
    public shape: Shape
  ) {}

  // 绘制中梃的方法
  draw(ctx: CanvasContext): void {
    ctx.beginPath();
    if (this.type === 'horizontal') {
      ctx.moveTo(this.dimension.length, this.dimension.width / 2);
      ctx.lineTo(this.dimension.length + this.dimension.width, this.dimension.width / 2);
    } else {
      ctx.moveTo(this.dimension.length / 2, this.dimension.width);
      ctx.lineTo(this.dimension.length / 2, this.dimension.width + this.dimension.height);
    }
    ctx.lineWidth = this.dimension.height;
    ctx.stroke();
  }
}
